var vm_zhuanjia = new Vue({
	el : "#zhuanjia",
	data : {
		//deptid : '001001',		// deptid
		deptid : $("#deptid").val(),		// deptid
		olddeptid : $("#olddeptid").val(),		// deptid
		
		zhuanjialist : [],// 专家列表custom
		zhuanjiaid : '',//专家id
		zhuanjia : {},//专家

		//查询用字段
		xingming : '',
		guoji : '',
		zhengjianleixing : '',
		zhengjianhaoma : '',
		ruxuannianfen : '',
		gongzuodanwei : '',
		zhuanjiazhuangtai : '',
		zhuangtaibiandongshijian : '',

		pageindex : 1,		// 查询分页初始化页
		pagesize : 10,		// 查询分页初始化页面大小
		pageCount : 0,		// 总页数
		recordCount : 0,	// 总记录数
		targetpage : '', 	// 目标页
	},
	created : function(){
		var _this = this;

		_this.bindZhuanjiaList();
		
	},
	watch : {
		//监控分页情况，刷新列表
		pageindex : function(){
			this.bindZhuanjiaList();
		},

		pagesize : function(){
			this.bindZhuanjiaList();
		},
	},
	methods : {

		//
		bindZhuanjiaList : function(){
			var _this = this;

			var zhuanjia_layer = layer.open({type:3});
			$.post('/system/zhuanjia/customlist', {
				deptid : _this.deptid,
				xingming : _this.xingming,
				guoji : _this.guoji,
				zhengjianleixing : _this.zhengjianleixing,
				zhengjianhaoma : _this.zhengjianhaoma,
				ruxuannianfen : _this.ruxuannianfen,
				gongzuodanwei : _this.gongzuodanwei,
				zhuanjiazhuangtai : _this.zhuanjiazhuangtai,
				zhuanjiabiandongshijian : _this.zhuanjiabiandongshijian,
				pageindex : _this.pageindex,
				pagesize : _this.pagesize,
				rdm : Math.random()
			},function(ppData) {
				layer.close(zhuanjia_layer);

				if (ppData != null) {
					var data = ppData.resultContent;

					_this.zhuanjialist = data.zhuanjialist;

					var pageInfo = data.PageInfo;
					_this.pageindex = pageInfo.pageIndex;
					_this.pageCount = pageInfo.pageCount;
					_this.recordCount = pageInfo.recordCount;
					_this.targetpage = '';
				}
			},"json");
		},

		bindZhuanjia : function(){
			var _this = this;

			var zhuanjia_layer = layer.open({type:3});
			$.post('/system/zhuanjia/findone', {
				zhuanjiaid : _this.zhuanjiaid,
				rdm : Math.random()
			},function(ppData) {
				layer.close(zhuanjia_layer);

				if(ppData != null){

					if(ppData.result == "1"){
						var data = ppData.resultContent;
						_this.zhuanjia = data;
						_this.zhuanjia.zhuanjiaid = _this.zhuanjiaid;
					}else{
						layer.alert(ppData.message);
					}
				}
			},"json");
		},

		toModify:function(ppZhuanjiaId){

			$("#myModalLabel").html("修改专家信息");
			$("#modal-dialog").attr("style","width:1200px;");
			$("#zhuanjiaModal").modal();

			this.zhuanjiaid = ppZhuanjiaId;

			this.zhuanjia = {};
			// 绑定专家
			this.bindZhuanjia();
		},

		// 修改专家信息
		modify : function(){
			var _this = this;
			if (_this.checkInputData()) {
				var zhuanjia_layer = layer.open({type: 3});
				$.post('/system/zhuanjia/edit', {
					zhuanjiaid: _this.zhuanjiaid,
					xingming: _this.zhuanjia.xingming,
					xingbie: _this.zhuanjia.xingbie,
					chushengriqi: _this.zhuanjia.chushengriqi,
					zhengjianleixing: _this.zhuanjia.zhengjianleixing,
					zhengjianhaoma: _this.zhuanjia.zhengjianhaoma,
					guoji: _this.zhuanjia.guoji,
					jiaoyuchengdu: _this.zhuanjia.jiaoyuchengdu,
					gongzuodanwei: _this.zhuanjia.gongzuodanwei,
					suoshuhangye: _this.zhuanjia.suoshuhangye,
					shoujihaoma: _this.zhuanjia.shoujihaoma,
					dianhuahaoma: _this.zhuanjia.dianhuahaoma,
					dianziyoujian: _this.zhuanjia.dianziyoujian,
					youbian: _this.zhuanjia.youbian,
					dizhi: _this.zhuanjia.dizhi,
					ruxuannianfen: _this.zhuanjia.ruxuannianfen,
					zhuanjiazhuangtai: _this.zhuanjia.zhuanjiazhuangtai,
					qushishijian: _this.zhuanjia.qushishijian,
					lianxiren1: _this.zhuanjia.lianxiren1,
					lianxidianhua1: _this.zhuanjia.lianxidianhua1,
					yuzhuanjiaguanxi1: _this.zhuanjia.yuzhuanjiaguanxi1,
					lianxiren2: _this.zhuanjia.lianxiren2,
					lianxidianhua2: _this.zhuanjia.lianxidianhua2,
					yuzhuanjiaguanxi2: _this.zhuanjia.yuzhuanjiaguanxi2,
					lianxiren3: _this.zhuanjia.lianxiren3,
					lianxidianhua3: _this.zhuanjia.lianxidianhua3,
					yuzhuanjiaguanxi3: _this.zhuanjia.yuzhuanjiaguanxi3,
					yinhangmingcheng: _this.zhuanjia.yinhangmingcheng,
					yinhangzhanghao: _this.zhuanjia.yinhangzhanghao,
					rdm: Math.random()
				}, function (ppData) {
					layer.close(zhuanjia_layer);
					if (ppData != null) {

						if (ppData.code == "0") {
							layer.open({
								time: 1000,
								btn: [],
								content: "保存成功!",
							});

							_this.bindZhuanjiaList();
							$("#zhuanjiaModal").modal('hide');

						} else {
							layer.alert(ppData.msg);
						}
					}
				}, "json");
			}
		},

		getDate_chushengriqi:function(){
			var _this = this;

			_this.zhuanjia.chushengriqi=$("#chushengriqi").val();
		},

		getDate_qushishijian:function(){
			var _this = this;

			_this.zhuanjia.qushishijian=$("#qushishijian").val();
		},

		//检查项目数据
		checkInputData : function() {
			if (!$.trim(this.zhuanjia.xingming)) {
				layer.alert("请填写姓名！");
				return false;
			}
			if (!$.trim(this.zhuanjia.xingbie)) {
				layer.alert("请选择性别！");
				return false;
			}
			if (!$.trim(this.zhuanjia.chushengriqi)) {
				layer.alert("请填写出生日期！");
				return false;
			}
			if (!$.trim(this.zhuanjia.zhengjianleixing)) {
				layer.alert("请选择证件类型！");
				return false;
			}
			if (!$.trim(this.zhuanjia.zhengjianhaoma)) {
				layer.alert("请填写证件号码！");
				return false;
			}
			if (!$.trim(this.zhuanjia.gongzuodanwei)) {
				layer.alert("请填写工作单位！");
				return false;
			}
			if (!$.trim(this.zhuanjia.ruxuannianfen)) {
				layer.alert("请填写入选年份！");
				return false;
			}
			if (!$.trim(this.zhuanjia.yinhangmingcheng)) {
				layer.alert("请填写银行名称！");
				return false;
			}
			if (!$.trim(this.zhuanjia.yinhangzhanghao)) {
				layer.alert("请填写银行帐号！");
				return false;
			}

			return true;
		},

		refresh:function(){
			var _this = this;

			//
			_this.bindZhuanjiaList();
		},

		toShowHistory:function(ppZhuanjiaId){
			History.zhuanjiaid = ppZhuanjiaId;

			History.showHistoryModel();
		},

		//首页
		firstPage : function(){
			this.pageindex = 1;
		},
		//尾页
		lastPage : function(){
			this.pageindex = this.pageCount;
		},
		//上一页
		prePage : function(){
			var prePage = ((this.pageindex -1) <= 0) ? 1 : (this.pageindex -1);
			this.pageindex = prePage;
		},
		//下一页
		nextPage : function(){
			var nextPage = ((this.pageindex +1) >= this.pageCount) ? this.pageCount : (this.pageindex +1);
			this.pageindex = nextPage;
		},
		//跳到目标页
		targetPage : function() {
			if( this.targetpage != '' && this.targetpage <= this.pageCount && this.targetpage > 0){
				this.pageindex = this.targetpage;
				this.targetpage = '';
			}
		},

	},
})